﻿
Partial Class GoodsRobot
    Inherits System.Web.UI.Page
    Dim CArray(40, 13)
    Dim TempCArray(40, 13)
    Public Shared Function MD5(ByVal strSource As String, ByVal Code As Int16) As String
        '这里用的是ascii编码密码原文，如果要用汉字做密码，可以用UnicodeEncoding，但会与ASP中的MD5函数不兼容 
        Dim dataToHash As Byte() = (New System.Text.ASCIIEncoding).GetBytes(strSource)
        Dim hashvalue As Byte() = CType(System.Security.Cryptography.CryptoConfig.CreateFromName("MD5"), System.Security.Cryptography.HashAlgorithm).ComputeHash(dataToHash)
        Dim i As Integer
        Select Case Code
            Case 16 '´选择16位字符的加密结果 
                For i = 4 To 11
                    MD5 += Hex(hashvalue(i)).ToLower
                Next
            Case 32 ' ´选择32位字符的加密结果 
                For i = 0 To 15
                    MD5 += Hex(hashvalue(i)).ToLower
                Next
            Case Else ' ´Code错误时，返回全部字符串，即32位字符 
                For i = 0 To hashvalue.Length - 1
                    MD5 += Hex(hashvalue(i)).ToLower
                Next
        End Select
    End Function
    Function EncodeBase64(ByVal StrA)
        Dim BufferA As Byte()
        BufferA = System.Text.Encoding.Default.GetBytes(StrA)
        Dim StrB As String
        StrB = Convert.ToBase64String(BufferA)
        EncodeBase64 = StrB
    End Function
    Function DecodeBase64(ByVal StrA)
        DecodeBase64 = Encoding.GetEncoding("gb2312").GetString(Convert.FromBase64String(StrA))
    End Function
    Function getstr(ByVal iRemote)
        Dim xPost, sGet
        iRemote = iRemote
        xPost = SERVER.CreateObject("msxml2.serverxmlhttp") 'msxml2.serverxmlhttp
        xPost.Open("GET", iRemote, False)
        xPost.setrequestheader("referer", "http://taoke.alimama.com/spreader/search_auction.htm")
        xPost.Send()
        sGet = CreateObject("ADODB.Stream")
        sGet.Mode = 3
        sGet.Type = 1
        sGet.Open()
        On Error Resume Next

        sGet.Write(xPost.responseBody)
        sGet.Position = 0
        sGet.Type = 2
        sGet.Charset = "gb2312" ' "gb2312"
        getstr = sGet.ReadText
    End Function

    Function gethtml(ByVal tmp, ByVal s, ByVal e, ByVal id)
        'On Error Resume Next
        Dim String1, String2, arrstr, j
        String1 = s
        String2 = e
        Dim fbegin
        Dim fend
        fbegin = 1
        fend = 1
        j = 0
        Do
            fbegin = InStr(fbegin, tmp, String1)
            If fbegin = 0 Then Exit Function
            fend = InStr(fbegin, tmp, String2)
            arrstr = Mid(tmp, fbegin + Len(String1), fend - (fbegin + Len(String1)))
            If id <> -1 Then
                CArray(j, id) = arrstr
                j = j + 1
            End If
            gethtml = arrstr
            If id = -1 Then Exit Function
            fbegin = fend + Len(String2)
        Loop While True
    End Function


    Function LoadFile(ByVal File)
        Dim objStream
        On Error Resume Next
        objStream = Server.CreateObject("ADODB.Stream")
        If Err.Number = -2147221005 Then
            Response.Write(DecodeBase64("PGRpdiBhbGlnbj0nY2VudGVyJz63x7Oj0sW6tizE+rXE1ve7+rK71qez1kFET0RCLlN0cmVhbdfpvP4szt63qNX9s6O9+NDQyM/WpLrNssm8ryE8L2Rpdj48YSBocmVmPWh0dHA6Ly96aHVqaS50YW9kZC5vcmcgdGFyZ2V0PV9ibGFuaz7M1LartqvW97v6LM3qw8DWp7PWzNS2q7arMi4wPC9hPg=="))
            Err.Clear()
            Response.End()
        End If
        With objStream
            .Type = 2
            .Mode = 3
            .Open()
            .LoadFromFile(Server.MapPath(File))
            If Err.Number <> 0 Then
                response.write(DecodeBase64("PHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPmFsZXJ0KCe21LK7xvCjrEtFWdLRyqfQp6Osx+vW2NDCyM/WpEtFWSEnKTt0aGlzLmxvY2F0aW9uLmhyZWY9J2h0dHA6Ly93d3cudGFvZGQub3JnJzs8L3NjcmlwdD48YSBocmVmPWh0dHA6Ly93d3cudGFvZGQub3JnPrXj1eLA78/C1NjQwrXEytrIqM7EvP48L2E+"))
                Err.Clear()
                Response.End()
            End If
            .Charset = "GB2312"
            .Position = 2
            LoadFile = .ReadText
            .Close()
        End With
        objStream = Nothing
    End Function



    Public Shared Function MD5x(ByVal strSource As String, ByVal Code As Int16) As String
        '这里用的是ascii编码密码原文，如果要用汉字做密码，可以用UnicodeEncoding，但会与ASP中的MD5函数不兼容 
        Select Case Code
            Case 16 '´选择16位字符的加密结果 
                MD5x = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strSource, "MD5").ToLower().Substring(8, 16)
            Case 32 ' ´选择32位字符的加密结果 
                MD5x = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strSource, "MD5").ToLower()
        End Select
    End Function
    Protected Sub GoodsRobot_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' response.write(DecodeBase64("aHR0cDovL3N1cHBvcnQudGFvZGQub3JnL3Blcm1pc3Npb24uYXNweA==") & "?key=" & EncodeBase64(Request.ServerVariables("server_name") & "/_\" & DateTime.Today))
        ' response.end()
        Dim i
        If Request.Cookies("TaoddAdmin") Is Nothing Or Request.Cookies("TaoddPassWord") Is Nothing Then
            Response.Redirect("login.aspx")
        Else
            PassPortCheck()
        End If
        Dim c, connstr, conn, rs, rs1
        connstr = ConfigurationSettings.AppSettings("SQLConnString") & """" & Server.MapPath(".") & "\..\" & ConfigurationSettings.AppSettings("dbPath") & """"
        conn = Server.CreateObject("ADODB.Connection")
        conn.open(connstr)
        rs = Server.CreateObject("adodb.recordset")
        rs1 = Server.CreateObject("adodb.recordset")
        If Request("Action") = "GetSmallClass" Then
            rs.open("select   *  from catclass where ParentID=" & Int(Request.QueryString("cid")), conn, 1, 3)
            Response.Write("GetSmallClass|" & Request.QueryString("cid") & "|")
            Response.Write("<font style=""font-size:12px; width:320px;color:#FF0000;display:inline;"">该分类有" & rs.recordcount & "个小分类</font>")
            If rs.recordcount > 5 Then Response.Write("<a href=""javascript:void(0)"" onClick=""check_Small('Small" & Request.QueryString("cid") & "')"">[全选]</a><a href=""javascript:void(0)"" onClick=""check_Small_no('Small" & Request.QueryString("cid") & "')"">[全不选]</a>")
            Response.Write("<ul style=""display:inline;width:800px"">")
            While Not rs.eof
                Response.Write("<li style=""width:190px;display:inline; font-size:12px; color:#0000CC;float:left;""><input type=""checkbox"" name=""catid" & rs("catid").value & """ id=""catid" & rs("catid").value & """ CatName=""" & rs("catname").value & """  value=""" & rs("catid").value & """>" & rs("catname").value & "</li>" & vbNewLine)
                rs.movenext()
            End While
            Response.Write("<li style=""width:800px; color:#cccccc; border-bottom:1px dotted  #cccccc""></li></ul>")
            rs.close()
            Response.End()
        End If
        If Request("Action") = "Get" Then
            On Error Resume Next
            Dim url, tempcode, cid, a, CC, pagescount, curpage, h, Count, taokeurl, GoodsClass
            Dim ItemDescIUrl, ReviewsUrl, ItemViewsUrl, attributeslist, TaoBaoSale
            cid = Request("cid")
            If cid = "" Then cid = 16
            Randomize()
            url = "http://taoke.alimama.com/spreader/auction_list.htm?c=&advsort=&mid=0&isMallRedirect=&q=&cat=" & cid & "&od=" & Request("od") & "&conts=" & Request("crs") & "&conte=" & Request("cre") & "&hs=" & Request("hs") & "&he=" & Request("he") & "&cs=" & Request("cs") & "&ce=" & Request("ce") & "&rs=" & Request("rs") & "&re=" & Request("re") & "&loc=" & Server.UrlEncode(Request("Loc")) & "&toPage=" & Request("page") & "&rnd=" & Rnd()
            tempcode = getstr(url)
     

            tempcode = Replace(tempcode, "100) page.max=", "")
            tempcode = Replace(tempcode, "if(page.max=", "")
            tempcode = Replace(tempcode, ") page.cur=", "")
            If InStr(tempcode, "page.max") = 0 Then
                pagescount = 1
                curpage = 1
            Else
                pagescount = gethtml(tempcode, "page.max=", ";", 10) '当前分类名字
                curpage = gethtml(tempcode, "page.cur=", ";", 10) '当前分类名字
            End If

            tempcode = Replace(tempcode, "<span class=""H"">", "")
            tempcode = Replace(tempcode, "</span>", "")

            tempcode = getText(tempcode, "<div id=""listview"">", "<!--列表 结束-->")
            CC = Split(tempcode, "<div class=""zck_list1"">")
            CC = UBound(CC)
            a = gethtml(tempcode, "<a class=""blue_14""", "</li>", 0)  '商品名称
            a = gethtml(tempcode, "<div class=""preprice"">", "元", 1)  '商品价格
            a = gethtml(tempcode, "<div class=""yjbl"">", "</div>", 6)  '佣金比例
            a = gethtml(tempcode, "target=""_blank""><img src=""", """ onerror=", 5)  '商品PIC
            a = gethtml(tempcode, "<input type=""checkbox"" value=""", """ ac_data=", 4)  '商品ID
            a = gethtml(tempcode, "掌柜:<a class=""grey_12", "/a>", 11)  '商品掌柜
            a = gethtml(tempcode, "<div class=""lscj"">", "</div>", 12)  '累积推广量
            a = gethtml(tempcode, "shop/view_shop.htm?user_number_id=", """ target=""_blank", 9)  '累积推广量
            a = gethtml(tempcode, "<div class=""yj"">", "</div>", 7)  '累积推广量
            a = gethtml(tempcode, """auction_url"":""", """,""", 3)  '商品正常链接


            If pagescount = 100 Then CC = 100 * 40
            c = 0
            If Request("Count") = "-286" Then
                CC = 40
            Else
                If Request("Count") = "" Then
                    Count = 0
                Else
                    Count = Request("Count")
                End If
                CC = Int(Count)
            End If
            h = 0

            For i = 0 To 39
                If CArray(i, 1) <> "" Then

                    If c < CC Then
                        rs.open("select  top 1 *  from commodity where CID='" & CArray(i, 4) & "'", conn, 1, 3)
                        If rs.eof Then
                            rs.addnew()


                            CArray(i, 0) = gethtml(CArray(i, 0), """>", "</a>", 1)
                            rs("Name").value = CArray(i, 0)
                            rs("CID").value = CArray(i, 4)
                            rs("TaokeUrl").value = taokeurl
                            rs("Curl").value = "http://item.taobao.com/item.htm?id=" & CArray(i, 4)
                            rs("Price").value = CArray(i, 1)
                            CArray(i, 6) = gethtml(CArray(i, 6), "<font color=""#d02200"">", "%", 1)
                            CArray(i, 6) = Right(CArray(i, 6), Len(CArray(i, 6)) - 1)
                            rs("Rate").value = CArray(i, 6) ' * 100
                            CArray(i, 7) = gethtml(CArray(i, 7), "<font color=""#d02200"">", "</font>", 1)
                            CArray(i, 7) = Left(CArray(i, 7), Len(CArray(i, 7)) - 1)
                            CArray(i, 7) = Right(CArray(i, 7), Len(CArray(i, 7)) - 1)
                            rs("Commission").value = CArray(i, 7)
                            CArray(i, 11) = gethtml(CArray(i, 11), "_blank"">", "<", 1)
                            rs("Seller").value = CArray(i, 11)
                            CArray(i, 12) = Left(CArray(i, 12), Len(CArray(i, 12)) - 1)
                            CArray(i, 12) = Right(CArray(i, 12), Len(CArray(i, 12)) - 1)
                            rs("Sale").value = CArray(i, 12)
                            rs("Pic").value = CArray(i, 5)
                            ' rs("EXLEVEL").value = CArray(i, 13)
                            rs("ShopUserId").value = CArray(i, 9)
                            GoodsClass = 0
                            rs1.open("select  top 1 *  from [catclass] where catid=" & CArray(i, 8), conn, 1, 3)
                            If rs1.eof Then
                                GoodsClass = cid
                            Else
                                If rs1("ParentID").value <> cid Then
                                    GoodsClass = cid
                                Else
                                    GoodsClass = CArray(i, 8)
                                End If
                            End If
                            rs1.close()
                            rs("class").value = GoodsClass ' CArray(i, 8)
                            rs.update()
                            c = c + 1
                        End If
                        rs.close()
                        h = h + 1

                    End If
                End If
            Next
            If h <> 0 And c = 0 Then
                c = -999
            End If
            Response.Write(c)
            conn.close()
            Response.End()

        End If
    End Sub
    Function SerachSaller(ByVal Saller)
        Dim url, tempcode, a, i, max, k, taokeurl, spurl, spcode, rateurl, ratecode
        url = "http://taoke.alimama.com/spreader/search_shop_from_engine.do?_input_charset=gb2312&catid=0&schcontent=" & Server.UrlEncode(Saller)

        tempcode = getstr(url)
        If InStr(tempcode, ",""TITLE"":""") = 0 Then
            SerachSaller = "NO"
            Exit Function
        End If

        a = GetText1(tempcode, ",""TITLE"":""", """}", 0)  '店铺名称
        a = GetText1(tempcode, """CONTACT"":""", """,""ORIMEMBERID"":", 1)  '店铺主人
        a = GetText1(tempcode, ",""SHOPURL"":""", """,""ISCPS"":", 2) '店铺网址
        a = GetText1(tempcode, ",""EXLEVEL"":""", """,""STATUS"":", 3) '店铺等级
        a = GetText1(tempcode, """,""MEMBERID"":""", """,""EXLEVEL"":", 4) '店铺ID
        a = GetText1(tempcode, """,""PICTURL"":""", """,""CATNAME"":""", 5) '店铺店标
        a = GetText1(tempcode, ",""AUCTIONCOUNT"":""", """,""TOTALACTION"":", 6) '商品总量
        a = GetText1(tempcode, """,""TOTALACTION"":""", """,""SORTRANK"":", 7) '累计推广量
        a = GetText1(tempcode, """COMMISSIONRATE"":""", """,""RANK_SCORE"":", 8) '佣金比例*0.01
        a = GetText1(tempcode, "CATNAME"":""", """,""COMMISSIONRATE", 9) '店铺分类
        SerachSaller = ""
        max = Int(gettext(tempcode, ",""max"":", ",""cur"))
        ' Response.Write(max)
        ' Response.End()

        For i = 0 To 19
            If TempCArray(i, 1) = Saller Then

                Dim code, shopxinyong, shopEvaluation, BannerCode
                
                code = getstr(TempCArray(i, 2))
                If InStr(code, "<h4>淘宝商城</h4>") Then
                    shopxinyong = -1
                    shopEvaluation = "0"
                Else

                    shopxinyong = GetText1(code, "<span>卖家信用：</span>", "/a>", -1) '卖家信用1
                    shopxinyong = Replace(shopxinyong, "<span>", "")
                    shopxinyong = Replace(shopxinyong, "</span>", "")
                    If InStr(shopxinyong, "<span ") Then
                        shopxinyong = Right(shopxinyong, Len(shopxinyong) - InStrRev(shopxinyong, ">"))
                        shopxinyong = Left(shopxinyong, InStr(shopxinyong, "<") - 1)
                    Else
                        shopxinyong = GetText1(shopxinyong, """>", "<", -1) '卖家信用2
                    End If

                    shopEvaluation = gettext(code, "<span>卖家好评率：</span>", "</li>")
                    shopEvaluation = Replace(shopEvaluation, "<strong>", "")
                    shopEvaluation = Replace(shopEvaluation, "</strong>", "")
                    If shopxinyong = "" Or shopEvaluation = "" Then
                        rateurl = gethtml(code, "http://rate.taobao.com/user-rate-", ".htm", -1)
                        ratecode = getstr("http://rate.taobao.com/user-rate-" & rateurl & ".htm")
                        'Response.Write("http://rate.taobao.com/user-rate-" & rateurl & ".htm---")
                        shopxinyong = gethtml(ratecode, "#RateType"" >" & vbNewLine & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & vbTab & vbTab & vbTab & vbTab, vbNewLine & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & vbTab & vbTab & vbTab & "</a>", -1)
                        shopEvaluation = gethtml(ratecode, "好评率：<strong>", "%</strong>", -1)
                    End If

                End If
                BannerCode = Left(code, InStr(code, "<em>首页</em>"))
                If InStr(BannerCode, "-image: url") Then
                    BannerCode = getText(BannerCode, "-image: url", " title=""首页""")
                Else
                    BannerCode = getText(BannerCode, "flash-banner", " title=""首页""")
                End If
                If InStr(BannerCode, "shop-title") Then
                    BannerCode = ""
                Else
                    If InStr(BannerCode, "embed") Then
                        BannerCode = "<embed " & getText(BannerCode, "<embed ", "transparent""/>") & "transparent""/>"
                    Else
                        If getText(BannerCode, "(", ");") <> "" Then
                            BannerCode = "<img src=""" & getText(BannerCode, "(", ");") & """ />"
                        Else
                            BannerCode = ""
                        End If
                    End If
                End If
                If InStr(getstr(TempCArray(i, 2)), "没有找到相应的店铺信息") Then
                    SerachSaller = "Fail"
                    Exit Function
                End If

                url = "http://taoke.alimama.com/spreader/gen_shop_code.htm?pid=" & TempCArray(i, 4)
                tempcode = getstr(url)
                taokeurl = Replace(GetText1(tempcode, "txt_urlcode"" name=""foroverflow"">", "</textarea>", -1), "10011550", "")
                SerachSaller = TempCArray(i, 1) & "|" & TempCArray(i, 2) & "|" & TempCArray(i, 4) & "|" & taokeurl & "|" & shopxinyong & "|" & shopEvaluation & "|" & BannerCode
            End If
        Next

        If SerachSaller = "" Then
            max = Int(gettext(tempcode, ",""max"":", ",""cur"))
            If max > 1 Then
                For i = 2 To max
                    url = "http://taoke.alimama.com/spreader/search_shop_from_engine.do?_input_charset=gb2312&catid=0&schcontent=" & Server.UrlEncode(Saller) & "&p=" & i
                    tempcode = getstr(url)
                    ReDim TempCArray(40, 10)
                    'Response.Write(tempcode)
                    a = GetText1(tempcode, ",""TITLE"":""", """}", 0)  '店铺名称
                    a = GetText1(tempcode, """CONTACT"":""", """,""ORIMEMBERID"":", 1)  '店铺主人
                    a = GetText1(tempcode, ",""SHOPURL"":""", """,""ISCPS"":", 2) '店铺网址
                    a = GetText1(tempcode, ",""EXLEVEL"":""", """,""STATUS"":", 3) '店铺等级
                    a = GetText1(tempcode, """,""MEMBERID"":""", """,""EXLEVEL"":", 4) '店铺ID
                    a = GetText1(tempcode, """,""PICTURL"":""", """,""CATNAME"":""", 5) '店铺店标
                    a = GetText1(tempcode, ",""AUCTIONCOUNT"":""", """,""TOTALACTION"":", 6) '商品总量
                    a = GetText1(tempcode, """,""TOTALACTION"":""", """,""SORTRANK"":", 7) '累计推广量
                    a = GetText1(tempcode, """COMMISSIONRATE"":""", """,""RANK_SCORE"":", 8) '佣金比例*0.01
                    a = GetText1(tempcode, "CATNAME"":""", """,""COMMISSIONRATE", 9) '店铺分类
                    For k = 0 To 19
                        If TempCArray(k, 1) = Saller Then

                            Dim code, shopxinyong, shopEvaluation, BannerCode
                            'response.write(TempCArray(i, 2))
                            code = getstr(TempCArray(i, 2))
                            If InStr(code, "<h4>淘宝商城</h4>") Then
                                shopxinyong = -1
                                shopEvaluation = "0"
                            Else

                                shopxinyong = GetText1(code, "<span>卖家信用：</span>", "/a>", -1) '卖家信用1
                                shopxinyong = Replace(shopxinyong, "<span>", "")
                                shopxinyong = Replace(shopxinyong, "</span>", "")
                                If InStr(shopxinyong, "<span ") Then
                                    shopxinyong = Right(shopxinyong, Len(shopxinyong) - InStrRev(shopxinyong, ">"))
                                    shopxinyong = Left(shopxinyong, InStr(shopxinyong, "<") - 1)
                                Else
                                    shopxinyong = GetText1(shopxinyong, """>", "<", -1) '卖家信用2
                                End If

                                shopEvaluation = gettext(code, "<span>卖家好评率：</span>", "</li>")
                                shopEvaluation = Replace(shopEvaluation, "<strong>", "")
                                shopEvaluation = Replace(shopEvaluation, "</strong>", "")
                                If shopxinyong = "" Or shopEvaluation = "" Then
                                    rateurl = gethtml(code, "http://rate.taobao.com/user-rate-", ".htm", -1)
                                    ratecode = getstr("http://rate.taobao.com/user-rate-" & rateurl & ".htm")
                                    shopxinyong = gethtml(ratecode, "#RateType"" >" & vbNewLine & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & vbTab & vbTab & vbTab & vbTab, vbNewLine & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & Space(1) & vbTab & vbTab & vbTab & "</a>", -1)
                                    shopEvaluation = gethtml(ratecode, "好评率：<strong>", "%</strong>", -1)
                                End If
                            End If
                            BannerCode = left(code, instr(code, "<em>首页</em>"))
                            If instr(BannerCode, "-image: url") Then
                                BannerCode = gettext(BannerCode, "-image: url", " title=""首页""")
                            Else
                                BannerCode = gettext(BannerCode, "flash-banner", " title=""首页""")
                            End If
                            If instr(BannerCode, "shop-title") Then
                                BannerCode = ""
                            Else
                                If instr(BannerCode, "embed") Then
                                    BannerCode = "<embed " & gettext(BannerCode, "<embed ", "transparent""/>") & "transparent""/>"
                                Else
                                    If gettext(BannerCode, "(", ");") <> "" Then
                                        BannerCode = "<img src=""" & gettext(BannerCode, "(", ");") & """ />"
                                    Else
                                        BannerCode = ""
                                    End If
                                End If
                            End If
                            If instr(getstr(TempCArray(i, 2)), "没有找到相应的店铺信息") Then
                                SerachSaller = "Fail"
                                Exit Function
                            End If
                            url = "http://taoke.alimama.com/spreader/gen_shop_code.htm?pid=" & TempCArray(i, 4)
                            tempcode = getstr(url)
                            taokeurl = Replace(GetText1(tempcode, "txt_urlcode"" name=""foroverflow"">", "</textarea>", -1), "10011550", "")

                            SerachSaller = TempCArray(i, 1) & "|" & TempCArray(i, 2) & "|" & TempCArray(i, 4) & "|" & taokeurl & "|" & shopxinyong & "|" & shopEvaluation & "|" & BannerCode
                        End If
                    Next
                Next
            End If
        End If
        If SerachSaller = "" Then SerachSaller = "NO"
    End Function
    Function GetText1(ByVal tmp, ByVal s, ByVal e, ByVal id)
        On Error Resume Next
        Dim String1, String2, arrstr, j
        String1 = s
        String2 = e
        Dim fbegin
        Dim fend
        fbegin = 1
        fend = 1
        j = 0
        Do
            fbegin = InStr(fbegin, tmp, String1)
            If fbegin = 0 Then Exit Function
            fend = InStr(fbegin, tmp, String2)
            arrstr = Mid(tmp, fbegin + Len(String1), fend - (fbegin + Len(String1)))
            GetText1 = arrstr
            If id <> -1 Then
                TempCArray(j, id) = arrstr
                j = j + 1
            Else
                Exit Function
            End If


            fbegin = fend + Len(String2)
        Loop While True
    End Function
    Function getText(ByVal tmp, ByVal s, ByVal e)
        'On Error Resume Next
        Dim String1, String2, arrstr, j
        String1 = s
        String2 = e
        Dim fbegin
        Dim fend
        fbegin = 1
        fend = 1
        Do
            fbegin = InStr(fbegin, tmp, String1)
            If fbegin = 0 Then Exit Function
            fend = InStr(fbegin, tmp, String2)
            arrstr = Mid(tmp, fbegin + Len(String1), fend - (fbegin + Len(String1)))
            getText = arrstr
            fbegin = fend + Len(String2)
        Loop While True
    End Function
    Function PassPortCheck()
        Dim connstr, connA, rsA
        connstr = ConfigurationSettings.AppSettings("SQLConnString") & """" & Server.MapPath(".") & "\..\" & ConfigurationSettings.AppSettings("dbPath") & """"
        connA = Server.CreateObject("ADODB.Connection")
        connA.open(connstr)
        Dim Admin_UserName, Admin_UserPass
        Admin_UserName = replace(Request.Cookies("TaoddAdmin").value, "'", "''")
        Admin_UserPass = replace(Request.Cookies("TaoddPassWord").value, "'", "''")
        rsA = Server.CreateObject("adodb.recordset")
        rsA.open("select * from [admin^] where Admin_UserName='" & Admin_UserName & "' and Admin_UserPass='" & Admin_UserPass & "'", connA, 1, 3)
        If rsA.eof Then
            Response.Redirect("login.aspx")
        End If
        connA.close()
        connA = Nothing
    End Function
End Class
